import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

///flutter_swiper https://github.com/best-flutter/flutter_swiper

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(
        title: "图片轮播",
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String title;

  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<Map> imgList = [
    {"url": "https://www.itying.com/images/flutter/1.png"},
    {"url": "https://www.itying.com/images/flutter/2.png"},
    {"url": "https://www.itying.com/images/flutter/3.png"},
    {"url": "https://www.itying.com/images/flutter/4.png"}
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Swiper(
        itemCount: imgList.length,
        pagination: SwiperPagination(),
        itemBuilder: (BuildContext context, int index) {
          return Image.network(
            imgList[index]["url"],
            fit: BoxFit.cover,
          );
        },
      ),
    );
  }
}
